package com.plm.k8s.myk8sapi.cmd;

import com.plm.k8s.myk8sapi.pojo.entity.pod.*;
import com.plm.k8s.myk8sapi.pojo.entity.sts.StsEntity;
import com.plm.k8s.myk8sapi.pojo.entity.sts.StsSpecVolumeClaimTemplateEntity;

import java.io.File;
import java.util.List;
import java.util.Map;

/**
 * StatefulSet相关命令
 * @author 潘磊明
 * 版本号：1.0
 * 创建日期：2021/7/28 16:58
 */
public interface IStsCmd {

    /**
     * 获取sts列表
     * @param isAll
     * @param namespace
     * @param nameFilter
     * @param labelFilter
     * @return
     * @throws Exception
     */
    List<StsEntity> listSts(boolean isAll, String namespace, String nameFilter, Map<String, String> labelFilter) throws Exception;

    /**
     * 根据yaml文件创建file
     * @param file
     * @return
     */
    boolean createSts(File file) throws Exception;

    /**
     * 创建sts
     * @param name
     * @param image
     * @param replicas
     * @param imagePullPolicy
     * @param envs
     * @param ports
     * @param volumeMounts
     * @param volumeClaimTemplates
     * @param namespace
     * @param terminationGracePeriodSeconds
     * @param command
     * @param startupProbe
     * @param livenessProbe
     * @param readinessProbe
     * @param lifecycle
     * @return
     */
    boolean createSts(String name, String image, String serviceName, Integer replicas, String imagePullPolicy, List<PodSpecContainerEnvEntity> envs,
            List<PodSpecContainerPortEntity> ports, List<PodSpecContainerVolumeMountEntity> volumeMounts,
            List<StsSpecVolumeClaimTemplateEntity> volumeClaimTemplates, String namespace, Integer terminationGracePeriodSeconds,
            List<String> command, PodSpecContainerStartupProbeEntity startupProbe,
            PodSpecContainerLivenessProbeEntity livenessProbe, PodSpecContainerReadinessProbeEntity readinessProbe,
            PodSpecContainerLifecycleEntity lifecycle) throws Exception;

    /**
     * 删除statefulset
     * @param name
     * @param namespace
     * @return
     */
    boolean deleteSts(String name, String namespace) throws Exception;

    /**
     * 扩容
     * @param name
     * @param replicas
     * @param namespace
     * @return
     */
    boolean scaleSts(String name, Integer replicas, String namespace) throws Exception;
}
